﻿package kizzo.utils 
{
	import fl.motion.easing.Quadratic;
	
	public class PropertyTweener extends BaseTweener 
	{
		protected var object:*;
		protected var property:String;
		protected var start_value:Number;
		protected var end_value:Number;
		protected var total_change:Number
		
		public function PropertyTweener(object:*, property:String, start_value:Number, end_value:Number, steps:uint = 10) 
		{
			this.object = object;			
			this.property = property;			
			this.start_value = start_value;
			this.end_value = end_value;
			this.total_change = end_value - start_value;			
			
			super(steps);
		}
		
		
		override protected function init():void
		{		
		
		}
		
		override protected function set_current(step:uint):void
		{			
			this.object[property] = Quadratic.easeInOut(step, start_value, this.total_change, this.steps);
			//trace (object + "." + property + ":" + object[property]);
		}
		
		
		public function set_start_value(start_value:Number):void
		{
			this.start_value = start_value;
			this.total_change = this.end_value - this.start_value;
		}
		
		public function set_end_value(end_value:Number):void
		{
			this.end_value = end_value;
			this.total_change = this.end_value - this.start_value;
		}
		
		public function get_current_value():Number
		{
			return this.object[property];
		}
	}
	
}